{% load inventree_extras %}
{% load i18n %}

{% if plugin %}
{% setting_object key cache=False plugin=plugin as setting %}
{% elif user_setting %}
{% setting_object key cache=False user=request.user as setting %}
{% elif notification_setting %}
{% setting_object key cache=False method=method user=request.user as setting %}
{% else %}
{% setting_object key cache=False as setting %}
{% endif %}

<tr>
    <td>
        {% if icon %}
        <span class='fas {{ icon }}'></span>
        {% endif %}
    </td>
    <td><strong>{{ setting.name }}</strong></td>
    <td>
        {{ setting.description }}
    </td>
    <td>
        {% if setting.is_bool %}
        {% include "InvenTree/settings/setting_boolean.html" %}
        {% else %}
        <div id='setting-{{ setting.pk }}'>
            <span id='setting-value-{{ setting.pk }}-{{ setting.typ }}' fieldname='{{ setting.key.upper }}'>
                {% if setting.value == '' %}
                <em style='color: #855;'>{% trans "No value set" %}</em>
                {% else %}
                {% if setting.is_choice %}
                <strong>{{ setting.as_choice }}</strong>
                {% else %}
                <strong>{{ setting.value }}</strong>
                {% endif %}
                {% endif %}
            </span>
            {{ setting.units }}
            <div class='btn-group float-right'>
                <button
                    class='btn btn-outline-secondary btn-small btn-edit-setting'
                    title='{% trans "Edit setting" %}'
                    pk='{{ setting.pk }}'
                    setting='{{ setting.key.upper }}'
                    {% if plugin %}plugin='{{ plugin.slug }}'{% endif %}
                    {% if user_setting or notification_setting %}user='{{request.user.id}}'{% endif %}
                    {% if notification_setting %}
                    notification=true
                    method='{{ setting.method }}'
                    {% endif %}
                >
                    <span class='fas fa-edit icon-green'></span>
                </button>
            </div>
        </div>
        {% endif %}
    </td>
</tr>
